package apps.sim.action.handler;

import java.io.IOException;

import apps.sim.core.AHandler;
import apps.sim.core.IHandler;

import com.sun.net.httpserver.HttpExchange;

public class EchoHandler extends AHandler {
	private String contentType;

	public byte[] handle(HttpExchange exchange, String context) throws IOException {
		contentType = exchange.getRequestHeaders().getFirst("Content-type");
		return IHandler.Util.readDataAsString(exchange.getRequestBody());
	}

	public String getDescription() {
		return "It returns request payload as response";
	}

	@Override
	public String getContentType() {
		return contentType;
	}

}
